#include<iostream>
using namespace std;

class Solution {
public:
	bool isPowerOfThree(int n) {
		if (n <= 0)return false;
		double a = log10(n) / log10(3);
		if (a-int(a) == 0)
		{
			return true;
		}
		else return false;
	}
};

int main()
{
	Solution *s = new Solution;
	cout << s->isPowerOfThree(0);
	return 0;
}